import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sports_new/entity/other/resource_entity.dart';
import 'package:sports_new/resources/colours.dart';
import 'package:sports_new/view/my/discount/tip_resources.dart';
import 'package:sports_new/widgets/base/qkd_button.dart';

import '../../../widgets/base/qkd_text.dart';

class MyDiscountDescribeDialog extends StatelessWidget {
  MyDiscountDescribeDialog({super.key});

  @override
  Widget build(BuildContext context) {
    return Dialog(
      backgroundColor: Colors.transparent,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [_content()],
      ),
    );
  }

  final List<ResourceEntity> tips = TipResources.discountDescribes ??
      [
        ResourceEntity(content: "1) 每个订单只能使用一张优惠券，不能累计重复使用。"),
        ResourceEntity(content: "2) 优惠券请在有效期内使用，不支持兑现、找零。"),
        ResourceEntity(content: "3) 优惠券仅支持允许使用“优惠券”的商品。"),
        ResourceEntity(content: "4) 使用优惠券下单后如取消订单，系统恢复该优惠券，并可以再次使用。")
      ];

  Widget _content() {
    return Container(
      width: 280,
      padding: const EdgeInsets.symmetric(horizontal: 16),
      decoration: BoxDecoration(
          color: Colors.white, borderRadius: BorderRadius.circular(8)),
      clipBehavior: Clip.hardEdge,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          Container(
            padding: const EdgeInsets.only(top: 8),
            height: 62,
            alignment: Alignment.center,
            child: QkdText(
              "优惠券使用说明",
              fontSize: 16,
              fontWeight: FontWeight.w600,
            ),
          ),
          ...tips.map((e) => QkdText(
            e.content ?? "",
            color: Colours.grey66
          ).marginOnly(bottom: 5)),
          QkdButton(
            onPressed: Get.back,
            height: 44,
            backgroundColor: Colours.main,
            foregroundColor: Colors.white,
            borderRadius: 4,
            text: "知道了"
          ).marginOnly(bottom: 24, top: 16)
        ],
      ),
    );
  }
}

class MyDiscountDescribePage extends StatefulWidget {
  const MyDiscountDescribePage({super.key});

  @override
  State<MyDiscountDescribePage> createState() => _MyDiscountDescribePageState();
}

class _MyDiscountDescribePageState extends State<MyDiscountDescribePage> {
  @override
  Widget build(BuildContext context) {
    return const Scaffold();
  }
}
